package com.yunhe.mybatis.web.user;

import com.yunhe.mybatis.entity.Deparment;
import com.yunhe.mybatis.service.DeparmentService;
import com.yunhe.mybatis.service.UserService;
import com.yunhe.mybatis.service.impl.DeparmentServiceImpl;
import com.yunhe.mybatis.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/user/add")
public class UserAddServlet extends HttpServlet {
        private DeparmentService deparmentService = new DeparmentServiceImpl();  //Service
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

           //取到的界面的clazz的值
            List<Deparment> deparment = deparmentService.findAll();
            req.setAttribute("deparment",deparment);

            req.getRequestDispatcher("/WEB-INF/user/add.jsp").forward(req,resp);
        }
}
